app.controller("income",function($scope,$uibModal,$rootScope,del,$state,get,$stateParams ){
	
		get.list("dictionary/subjectDic").then(function(e){
			$scope.itemArray = e
			$scope.itemArray.unshift({
				diName:"全部",
				diId:null
			})
				$scope.selected={
					value:{
						diName:"全部",
						diId:null
					}
				}
		})
	$scope.search=function(i){
		if($scope.selected==''||$scope.selected==null){
			$scope.selected={value: {
				diId:null
			}
			}
		}
		var param={
			pageNum:i||'1',
			pageSize:8,
			key:$scope.key||null,
			status:$scope.selected.value.diId||null,
			startTime:$scope.startTime,
			endTime:$scope.endTime
		}
		get.list("income/all",param).then(function(e){
			$scope.list=e.list
			$scope.pageSize = e.pageSize; //每页多少条
			$scope.totalNum = e.pageCount; //总共多少页
			$scope.totalSize =e.totalNums; //总共多少条   
			$scope.pageNum = e.pageNum; //当前页面
		})
		
   	
		
	
	}


	$scope.pageUp=function(){//跳转页码
       	if ($scope.tj.page>$scope.totalNum) {
       		$scope.tj.page=$scope.totalNum
       	} else if($scope.tj.page<1){
       	$scope.tj.page=null
       	}
       }//pageUp
   $scope.toPage=function(i){//点击跳转
       i=i||$scope.tj.page
       	$scope.search(i)
       	$scope.tj.current=$scope.tj.page;//页码调整
   }//toPage
   if($stateParams.page!=null){
			$scope.tj={
				page:$stateParams.page
			}
		 $scope.toPage($stateParams.page)
	}else{
			$scope.search();
	}
   /**
	 * 删除
	 */
	$scope.modelClick = function(id) { //单删
	$uibModal.open({ //模态框
		animation: true,
		templateUrl: 'myModalDel.html',
		size: 'sm',
		 backdrop: 'static' ,
		controller: function($uibModalInstance) {
			var $ctrl = this;
				$ctrl.state = true;
			$ctrl.ok = function() {
				del.list("income/del",{icId:id}).then(function(e){
					$uibModalInstance.close();
					$rootScope.open(e);
					$state.go("home.income",{page:$scope.pageNum},{
				     		reload:true
				     	})
				});
				
			}; //ok  
			$ctrl.cancel = function() {
				$uibModalInstance.close();
			};
		}, //controller
		controllerAs: '$ctrl'
	})
	}
})
